Learn how to select, prioritize, and set up searchable attributes for your Algolia index.
director
cast
title
genres
plot_summary
director
and cast
. If you think cast
should come before director
(for example, you want to see movies with Clint Eastwood before movies directed by Clint Eastwood), move cast
to the first place.director
and title
and decide that the movie’s name is more important than the director’s. That means you’d move title
to the second place and compare it with the previous one (cast
).title
, so you’d move it first. Then, because you don’t have any more attributes to compare title
to, you’d move on to genres
.title
as the first searchable attribute makes sense. But what if someone searched for “Clint Eastwood”? Would they primarily be looking for movies with Clint Eastwood, by Clint Eastwood, or both? In other words, how should you rank the director
and actors
attributes?
By putting director
first, movies that Clint Eastwood directed would come before those where he appeared as an actor. This may or may not be desirable. For example, if a user types “jane”, do you want to first display movies with director Jane Campion or actress Jane Fonda?
There’s no one-size-fits-all approach, and the strategy depends on your use case. Defining a priority order in your searchable attributes isn’t trivial. It can vary depending on your data, how it’s structured, what your users search for, and what they expect as results.
movie_title
, actor_name
, and director_name
at the same level. This way, if someone types “John”, the engine considers all three records equal in the attribute ranking criterion, and the engine would go to the next ranking criterion to try and break the tie.
title
as unordered
.
Things are different with the cast
attribute.
If users type “Scarlett Johansson,” chances are they would be more interested in movies where Scarlett Johansson has a leading role than movies where she played small parts.
Assuming that the order of actors and actresses in the cast
attribute reflects role size, keeping cast
ordered makes more sense.
searchableAttributes
when indexing.
If unordered isn’t set for an attribute, it will default to ordered when set by the API.
actors
attribute. If this attribute has the entire cast, it’s less efficient than if it only had the leading roles. Most users would probably look at leading roles when searching for an actor.
director
cast
title
genres
plot_summary
director
and cast
. If you think cast
should come before director
(for example, you want to see movies with Clint Eastwood before movies directed by Clint Eastwood), move cast
to the first place.director
and title
and decide that the movie’s name is more important than the director’s. That means you’d move title
to the second place and compare it with the previous one (cast
).title
, so you’d move it first. Then, because you don’t have any more attributes to compare title
to, you’d move on to genres
.name
or title
.
Suppose you have a “movies” index where the records have a genre
attribute with values like “crime” and “action.” Films fall into these categories, but there are also films whose titles and descriptions use these exact words, for example, “Crime Doesn’t Pay,” “Last Action Hero.”
In that case, you can decide that when a user searches for words that are more like genres, it’s best to search filter attributes before the title. This is guaranteed to return all crime movies whenever someone types in “crime,” regardless of the title.
Making this decision when setting up searchable attributes can significantly affect your results.